<template>
  <div class="cljktx">
    <!--  头部表单  -->
    <!-- <CarInfo v-if="isAutoAtion" :queryParams="queryParams"></CarInfo> -->
    <CarInfo :queryParams="queryParams"></CarInfo>
    <!--  提示信息 2列 左边面板 右边表格  -->
    <TiShiXinXi :queryParams="queryParams"></TiShiXinXi>
    <!--  预警信息 表格 -->
    <YuJingInfo></YuJingInfo>
    <!--  5个表格  -->
    <!-- <div v-if="isAutoAtion"> -->
    <div>
      <el-row>
        <el-col :span="24">活动</el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <HuoDong0 :queryParams="queryParams" @selectChange="huoDongSelectChange"></HuoDong0>
        </el-col>
        <el-col :span="12">
          <HuoDong1 :queryParams="queryParams"></HuoDong1>
        </el-col>
      </el-row>
      <el-row :gutter="20">
        <el-col :span="12">
          <YuYueAnPai :queryParams="queryParams" @selectChange="yuYueSelectChange"></YuYueAnPai>
        </el-col>
        <!-- <el-col :span="12">
        <ChuXianInfo :queryParams="queryParams"></ChuXianInfo>
        </el-col>-->
      </el-row>
      <!-- <el-row :gutter="20">
      <el-col :span="12">
        <XinNengYuan :queryParams="queryParams"></XinNengYuan>
      </el-col>
      </el-row>-->
      <div
        :style="{
          position: 'absolute',
          left: 0,
          bottom: 0,
          right: 0,
          zIndex: 9,
          borderTop: '1px solid #e9e9e9',
          padding: '10px 20px',
          background: '#fff',
          textAlign: 'center'
        }"
      >
        <el-button type="primary" @click="okBtnClick">确定</el-button>
        <el-button type="primary" @click="cancelBtnClick">取消</el-button>
      </div>
    </div>
  </div>
</template>

<script>
// import { getFwhdQdWxxmList, getFwhdQdWxclList, getFwhdQdfjxmList } from '@/api/repair/repairReception/customer/activity.js';
import { findBookingOrderLabour, queryAddItemBooking, queryPartBookingInfo } from '@/api/repair/repairReception/customer/monitoring.js';
import CarInfo from './CarInfo';
import TiShiXinXi from './TiShiXinXi';
import YuJingInfo from './YuJingInfo';
import HuoDong0 from './HuoDong0';
import HuoDong1 from './HuoDong1';
import YuYueAnPai from './YuYueAnPai';
import ChuXianInfo from './ChuXianInfo';
import XinNengYuan from './XinNengYuan';
import moment from 'moment';

export default {
  name: 'cljktx',
  components: {
    CarInfo,
    TiShiXinXi,
    YuJingInfo,
    HuoDong0,
    HuoDong1,
    YuYueAnPai,
    ChuXianInfo,
    XinNengYuan
  },
  props: {
    isAutoAtion: {
      type: Boolean,
      default() {
        return true;
      }
    },
    queryParams: {
      type: Object,
      // required: true,
      default() {
        // 需要传递的参数
        return {
          // 提示信息参数
          engineNo: '2564156',
          MODEL: 'WSPAD-TB5-2016-LincolnNavigatorCHN-YZBCA',
          SERIES: 'WSPAD-TB5-2016-LincolnNavigatorCHN',
          RONO: 'RO1901190001',
          // 活动 出险 预约 新能源 参数
          LICENSE: '陕A2FU00',
          vin: '09876543219876543',
          ownerNo: 'OW1907110001',
          BRAND: 'LINCOLN',
          MILEAGE: 999999,
          isRepairOrder: 'REPAIR_ORDER_TAG',
          dmsFuncId: 35100010,
          createDate: moment().format('YYYY-MM-DD HH-mm'),
          _: new Date().getTime(),
          order: null, // 预约单号
          customerDesc: '',
          remark: ''
        };
      }
    }
  },
  data() {
    return {
      huoDongSeletRow: [],
      yuYueSeletRow: []
    };
  },
  methods: {
    huoDongSelectChange(obj) {
      this.huoDongSeletRow = obj;
    },
    yuYueSelectChange(obj) {
      this.yuYueSeletRow = obj;
    },
    // 确定按钮事件
    async okBtnClick() {
      // 出参 活动选择内容
      const { huoDongSeletRow, yuYueSeletRow } = this;
      console.log('监控 确定', { huoDongSeletRow, yuYueSeletRow });
      let wxxmArr = [];
      let wxclArr = [];
      let fjxmArr = [];
      if (huoDongSeletRow.length > 0) {
        const arr = huoDongSeletRow.map(item => {
          return item['ACTIVITY_CODE'];
        });
        const code = arr.join(',');
        console.log('查询活动', code);
        const wxxm = await getFwhdQdWxxmList(code);
        const wxcl = await getFwhdQdWxclList(code);
        const fjxm = await getFwhdQdfjxmList(code);
        if (wxxm.data) {
          wxxmArr = [...wxxmArr, ...wxxm.data];
        }
        if (wxcl.data) {
          wxclArr = [...wxclArr, ...wxcl.data];
        }
        if (fjxm.data) {
          fjxmArr = [...fjxmArr, ...fjxm.data];
        }
      }

      if (yuYueSeletRow.length > 0) {
        const order = yuYueSeletRow[0]['BOOKING_ORDER_NO'];
        this.order = order;
        // 客户描述
        this.customerDesc = yuYueSeletRow[0]['CUSTOMER_DESC'];
        // 备注
        this.remark = yuYueSeletRow[0]['REMARK'];
        console.log('yuyueTest', yuYueSeletRow);
        console.log('查询预约', order);
        const wxxm = await findBookingOrderLabour(order);
        const fjxm = await queryAddItemBooking(order);
        const wxcl = await queryPartBookingInfo(order);
        if (wxxm.data) {
          wxxmArr = [...wxxmArr, ...wxxm.data];
        }
        if (wxcl.data) {
          wxclArr = [...wxclArr, ...wxcl.data];
        }
        if (fjxm.data) {
          fjxmArr = [...fjxmArr, ...fjxm.data];
        }
      }

      this.$emit('confirm', [wxxmArr, wxclArr, fjxmArr], this.order, this.customerDesc, this.remark);
    },
    // 取消按钮事件
    cancelBtnClick() {
      this.$emit('cancel');
    }
  }
};
</script>

<style lang="less" scoped></style>
